﻿using AutoMapper;

using Models;

using RESTfulDemo.Dtos;

namespace RESTfulDemo.Profiles {
    public class StudentInfoProfile : Profile {
        public StudentInfoProfile() {
            //将StudentInfo映射到StudentInfoDto
            CreateMap<StudentInfo, StudentInfoDto>();
            //将StudentInfoDto映射到StudentInfo
            CreateMap<StudentInfoDto, StudentInfo>()
                .ForMember(desc => desc.Guid, opt => opt.MapFrom(src => Guid.NewGuid()));

            CreateMap<StudentInfoUpdateDto, StudentInfo>();
            CreateMap<StudentInfo, StudentInfoUpdateDto>();
        }
    }
}
